package com.seeTools.boot.common.tools;

import cn.hutool.core.util.CharsetUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.asymmetric.KeyType;
import cn.hutool.crypto.asymmetric.RSA;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @Author: seeTools
 * @Date: 2024/9/9  15:48
 * @Version 1.0
 */
public class SeeToolsRSAUtils {

    public static final String PUBLIC_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuw26SBkq5s8ARzYb3UsIncJWNvLb2Rl8Vd+mwD07sRACdsJm9+3PMxadO4y4MNWo0+CRPmz+qRm6P3RnsztruX2crl0u/sdMv8mQI3zZTzGbZaXgIvrUX0uvOGpgJvuZP+nKxEyawmxC22qgmZ+Vw7ymF13BiQHhS9JPXUQG3LNTVHl7RkH4ROIeNMnnK1e2iRrIsldHcPQ6bc2Zjb4Sais71h3V8H0UOG8Uu/h7cXZ5qnQgYfEJvhveM9bnuLlDQd49I7TbGvNAuqO1wtGDL+DzwTjVIXAaEXGnrg1T3YV+jXIk5zZ3LpdAW8zc/gs1MpgyipJhmzW3P2Cwlq5u0QIDAQAB";
    public static final String PRIVATE_KEY = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC7DbpIGSrmzwBHNhvdSwidwlY28tvZGXxV36bAPTuxEAJ2wmb37c8zFp07jLgw1ajT4JE+bP6pGbo/dGezO2u5fZyuXS7+x0y/yZAjfNlPMZtlpeAi+tRfS684amAm+5k/6crETJrCbELbaqCZn5XDvKYXXcGJAeFL0k9dRAbcs1NUeXtGQfhE4h40yecrV7aJGsiyV0dw9DptzZmNvhJqKzvWHdXwfRQ4bxS7+HtxdnmqdCBh8Qm+G94z1ue4uUNB3j0jtNsa80C6o7XC0YMv4PPBONUhcBoRcaeuDVPdhX6NciTnNncul0BbzNz+CzUymDKKkmGbNbc/YLCWrm7RAgMBAAECggEAdVcvPHtNRm0kp4dyA2hGh3CZ1O6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dSjkA21dMNBvrq/WK1Kfo0nqWxlkXOU4BQ3S7LfTg3LCMRMnYLrovi7VQfB+pRI6oTaAE2zXh18NXGgk6rVqoeROkjPbzeNdUO1LFw=";
    private static final Logger logger = LoggerFactory.getLogger(SeeToolsRSAUtils.class);
    private static final RSA rsa = SecureUtil.rsa(PRIVATE_KEY, PUBLIC_KEY);

    public static String encrypt(String content) {
        return rsa.encryptBase64(content, CharsetUtil.CHARSET_UTF_8, KeyType.PublicKey);
    }

    public static String decrypt(String content) {
        return rsa.decryptStr(content, KeyType.PrivateKey, CharsetUtil.CHARSET_UTF_8);
    }

}
